<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Storage Utility Zipcode Test Page</title>

	<!--
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/fonts/fonts-min.css">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/button/assets/skins/sam/button.css">
-->
<script src="http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js" type="text/javascript"></script>

<!--end custom header content for this example-->

</head><body class="yui-skin-sam">

<script type="text/javascript">
YUI({combine: true, timeout: 10000, modules: {
        'gallery-number': {
            fullpath: 'http://core.localhost/assets/js/yahoo-3-ext/number.js',
//            fullpath: 'http://yui.yahooapis.com/gallery-2009.10.27/build/gallery-accordion/gallery-accordion-min.js',
            requires: [],
            optional: [],
            supersedes: []
        }
    }
}).use("node", "console", "test", "gallery-number", function (Y) {

    Y.namespace("example.test");

    Y.example.test.GalleryNumberTestCase = new Y.Test.Case({

        //the name of the test case - if not provided, one is automatically generated
        name: "Gallery Number Tests",

        /*
         * Specifies tests that "should" be doing something other than the expected.
         */
        _should: {

            /*
             * Tests listed in here should fail, meaning that if they fail, the test
             * has passed. This is used mostly for YuiTest to test itself, but may
             * be helpful in other cases.
             */
            fail: {

                //the test named "testFail" should fail
                testFail: false

            },

            /*
             * Tests listed here should throw an error of some sort. If they throw an
             * error, then they are considered to have passed.
             */
            error: {

                /*
                 * You can specify "true" for each test, in which case any error will
                 * cause the test to pass.
                 */
                testGenericError: true,

                /*
                 * You can specify an error message, in which case the test passes only
                 * if the error thrown matches the given message.
                 */
                testStringError: "I'm a specific error message.",
                testStringError2: "I'm a specific error message.",

                /*
                 * You can also specify an error object, in which case the test passes only
                 * if the error thrown is on the same type and has the same message.
                 */
                testObjectError: new TypeError("Number expected."),
                testObjectError2: new TypeError("Number expected."),
                testObjectError3: new TypeError("Number expected.")

            },

            /*
             * Tests listed here should be ignored when the test case is run. For these tests,
             * setUp() and tearDown() are not called.
             */
            ignore : {

                testIgnore: true

            }
        },

        //-------------------------------------------------------------------------
        // Basic tests - all method names must begin with "test"
        //-------------------------------------------------------------------------

		testDegrees: function() {
			Y.Assert.isTrue(isNaN(Y.Number.degrees('a')), '1');
			Y.Assert.areEqual(180, Y.Number.degrees(Math.PI), '2');
			Y.Assert.areEqual(2, Y.Number.degrees(2 * Math.PI /180), '2');
		},

		testFormat : function() {
			var n = 1111.11,
				formatDollars = '$0,0.00',
				formatPercent = '0.00%',
				formatRound = '0,000',
				formatText = 'Please add the $0,0.00 to my tab!';

			Y.Assert.areEqual('$1,111.11', Y.Number.format(n, formatDollars));
			Y.Assert.areEqual('1111.11%', Y.Number.format(n, formatPercent));
			Y.Assert.areEqual('1,111', Y.Number.format(n, formatRound));
			Y.Assert.areEqual('Please add the $1,111.11 to my tab!', Y.Number.format(n, formatText));
			Y.Assert.areEqual('0', Y.Number.format(0, '0'));
			Y.Assert.areEqual('0.00', Y.Number.format(0));
			Y.Assert.areEqual('0.01', Y.Number.format(0.011));
			Y.Assert.areEqual('1000', Y.Number.format(1000, '0'));
			Y.Assert.areEqual('1,000', Y.Number.format(1000, '0,0'));
			Y.Assert.areEqual('1,000.00', Y.Number.format(1000));
			Y.Assert.areEqual('10,000,000.00', Y.Number.format(10000000));
			Y.Assert.areEqual('$1,000', Y.Number.format(1000, '$0,0'));
		},

		testGetPrecision: function() {
			Y.Assert.areEqual(0, Y.Number.getPrecision(0));
			Y.Assert.areEqual(0, Y.Number.getPrecision(1000));
			Y.Assert.areEqual(2, Y.Number.getPrecision(1000.01));
			Y.Assert.areEqual(4, Y.Number.getPrecision(1000.0001));
			Y.Assert.areEqual(8, Y.Number.getPrecision(1000.00000001));
			Y.Assert.isNaN(Y.Number.getPrecision('asdf'));
		},

		testIsEven: function() {
			Y.Assert.isTrue(Y.Number.isEven(0), '1');
			Y.Assert.isFalse(Y.Number.isEven(1), '2');
			Y.Assert.isTrue(Y.Number.isEven(2), '3');
			Y.Assert.isFalse(Y.Number.isEven(3), '4');
			Y.Assert.isFalse(Y.Number.isEven(-1), '5');
			Y.Assert.isTrue(Y.Number.isEven(-12), '6');
			Y.Assert.isTrue(isNaN(Y.Number.isEven('a')), '7');
		},

		testIsBetween: function() {
			Y.Assert.isTrue(Y.Number.isBetween(1, 0, 2), '1');
			Y.Assert.isTrue(Y.Number.isBetween(0, 0, 2, true), '2');
			Y.Assert.isTrue(Y.Number.isBetween(2, 0, 2, true), '3');
			Y.Assert.isTrue(Y.Number.isBetween(-1, -0, -2), '4');
			Y.Assert.isTrue(Y.Number.isBetween(-0, 0, -2, true), '5');
			Y.Assert.isTrue(Y.Number.isBetween(-2, 0, -2, true), '6');
			Y.Assert.isTrue(Y.Number.isBetween(-1.1, -1, -2), '7');
			Y.Assert.isTrue(Y.Number.isBetween(1.1, 1, 2), '8');
			Y.Assert.isFalse(Y.Number.isBetween(1, 1, 2), '9');
			Y.Assert.isFalse(Y.Number.isBetween(-1, -1, -2), '10');
		},

		testIsNotBetween: function() {
			Y.Assert.isTrue(Y.Number.isNotBetween(0, 0, 2), '1');
			Y.Assert.isFalse(Y.Number.isNotBetween(0, 0, 2, true), '2');
			Y.Assert.isFalse(Y.Number.isNotBetween(2, 0, 2, true), '3');
			Y.Assert.isTrue(Y.Number.isNotBetween(-2, -0, -2), '4');
			Y.Assert.isFalse(Y.Number.isNotBetween(-0, 0, -2, true), '5');
			Y.Assert.isFalse(Y.Number.isNotBetween(-2, 0, -2, true), '6');
			Y.Assert.isTrue(Y.Number.isNotBetween(-0.1, -1, -2), '7');
			Y.Assert.isTrue(Y.Number.isNotBetween(0.1, 1, 2), '8');
			Y.Assert.isTrue(Y.Number.isNotBetween(1, 1, 2), '9');
			Y.Assert.isTrue(Y.Number.isNotBetween(-1, -1, -2), '10');
		},

		testIsOdd: function() {
			Y.Assert.isFalse(Y.Number.isOdd(0), '1');
			Y.Assert.isTrue(Y.Number.isOdd(1), '2');
			Y.Assert.isFalse(Y.Number.isOdd(2), '3');
			Y.Assert.isTrue(Y.Number.isOdd(3), '4');
			Y.Assert.isTrue(Y.Number.isOdd(-1), '5');
			Y.Assert.isFalse(Y.Number.isOdd(-12), '6');
			Y.Assert.isTrue(isNaN(Y.Number.isOdd('a')), '7');
		},

		testIsPrime: function() {
			Y.Assert.isFalse(Y.Number.isPrime(0), '1');
			Y.Assert.isFalse(Y.Number.isPrime(1), '2');
			Y.Assert.isTrue(Y.Number.isPrime(2), '3');
			Y.Assert.isTrue(Y.Number.isPrime(3), '4');
			Y.Assert.isTrue(Y.Number.isPrime(5), '5');
			Y.Assert.isTrue(Y.Number.isPrime(7), '6');
			Y.Assert.isTrue(Y.Number.isPrime(17), '7');
			Y.Assert.isFalse(Y.Number.isPrime(25), '8');
			Y.Assert.isFalse(Y.Number.isPrime(63), '9');
			Y.Assert.isTrue(Y.Number.isPrime(199), '10');
			Y.Assert.isFalse(Y.Number.isPrime(817), '11');
			Y.Assert.isTrue(Y.Number.isPrime(997), '12');
		},

		testRadians: function() {
			Y.Assert.isTrue(isNaN(Y.Number.radians('a')), '1');
			Y.Assert.areEqual(Math.PI, Y.Number.radians(180), '2');
			Y.Assert.areEqual(Math.PI / 2, Y.Number.radians(90), '3');
			Y.Assert.areEqual(Math.PI * 2, Y.Number.radians(360), '4');
		},

		testRandom: function() {
			Y.Assert.isTrue(Y.Number.isBetween(Y.Number.random(0), 0, 1, true));
			Y.Assert.isTrue(Y.Number.isBetween(Y.Number.random(1), 0, 1, true));
			Y.Assert.areEqual(100, Y.Number.random(100, 100));
			Y.Assert.isTrue(Y.Number.isBetween(Y.Number.random(100, 50), 50, 100, true));
			Y.Assert.isTrue(Y.Number.isBetween(Y.Number.random(-100, -50), -50, -100, true));
		},

		testRoundToDigit: function() {
			Y.Assert.areEqual(0, Y.Number.roundToDigit(0, 10), '1');
			Y.Assert.areEqual(-10, Y.Number.roundToDigit(-10, 10), '2');
			Y.Assert.areEqual(0, Y.Number.roundToDigit(2, 10), '3');
			Y.Assert.areEqual(10, Y.Number.roundToDigit(11, 10), '4');
			Y.Assert.areEqual(2, Y.Number.roundToDigit(2, 1), '5');
			Y.Assert.areEqual(11, Y.Number.roundToDigit(11, 1), '6');
			Y.Assert.areEqual(0, Y.Number.roundToDigit(11, 100), '7');
			Y.Assert.areEqual(1100, Y.Number.roundToDigit(1111, 100), '8');
			Y.Assert.areEqual(800, Y.Number.roundToDigit(799, 100), '9');
			Y.Assert.areEqual(1000, Y.Number.roundToDigit(799, 1000), '10');
			Y.Assert.areEqual(0, Y.Number.roundToDigit(499, 1000), '11');
		}

    });


    //create the console
    var r = new Y.Console({
        newestOnTop : false,
        style: 'block' // to anchor in the example content
    });

    r.render('#testLogger');

    Y.Test.Runner.add(Y.example.test.GalleryNumberTestCase);

    //run the tests
    Y.Test.Runner.run();
});

</script>

</body></html>